\documentclass[10pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{graphicx}


\begin{document}

\title{The Maths of Planet Warping}
\author{Jack Valmadre}
\maketitle

\section{Rectangular to Polar Co-ordinates}
\begin{figure}[ht]
\caption{Input image co-ordinates and polar coordinates.}
\label{fig:Coordinates}
\end{figure}
The simplest way to achieve a warp from rectangular to polar coordinates is,
\begin{align}
\theta(u) &= \frac{2\pi}{w} u \\
r(v) &= v
\end{align}
where $w$ is the width of the input image. However, this does not preserve pixel aspect ratio over the radius. Figure~\ref{fig:AspectProblem} shows how the image looks inflated near the centre and compressed towards the edges.

\begin{figure}[ht]
\caption{Infinitesimal area in rectangular and polar coordinates.}
\label{fig:Infinitesimal}
\end{figure}

Consider an infinitesimal area in both coordinate spaces. The width and height of the area is $(\delta u, \delta v)$ in rectangular coordinates, and $(r \delta \theta, \delta r)$ in polar coordinates. We require that the aspect ratio (the ratio of width to height) be preserved as $\delta \rightarrow 0$.
\begin{equation}
\frac{du}{dv} = \frac{r d\theta}{dr}
\end{equation}
\begin{equation}
\frac{1}{r} dr = \frac{d\theta}{du} dv
\end{equation}
\begin{equation}
\int \frac{1}{r} dr = \frac{2\pi}{w} \int dv
\end{equation}
\begin{equation}
\ln(r) = \frac{2\pi}{w} v + c
\end{equation}
\begin{equation}
r(v) = A \exp\left( \frac{2\pi}{w} v \right)
\end{equation}

This is looking good, but we kind of need $r(0) = 0$. I'm an engineer not a mathematician, so I won't lose any sleep over hacking in an offset to achieve this. If you think there's a more rigorous way of doing this, let me know.
\begin{equation}
r(v) = A \left[\exp\left(\frac{2\pi}{w} v\right) - 1\right]
\end{equation}

In this form, we can choose some scale constant $A$. In itself, $A$ doesn't have a clear physical meaning. I'd prefer to specify this scale factor in terms of the output image radius. Let $R$ be the output image radius, $h$ be the input image height.
\begin{equation}
r(h) = R 
\end{equation}
\begin{equation}
A = \frac{R}{\exp\left(\frac{2\pi}{w} h\right) - 1}
\end{equation}
\begin{equation}
r(v) = \frac{R \left[\exp\left(\frac{2\pi}{w} v\right) - 1\right]}{\exp\left(\frac{2\pi}{w} h\right) - 1}
\end{equation}


\end{document}
